﻿@using Fuse8.ContentManagementFramework.Web.MvcPowered
@model dynamic

@functions {private string GetCurrent(int i)
            {
                return i == 1 ? "b-current" : "";
            }

}

@helper GetParams(){
    
    foreach (string key in Request.QueryString.Keys)
    {
@:&@key=@Request.QueryString[key]
    }    
}

@helper GetDataParams(){
    
    foreach (string key in Request.QueryString.Keys)
    {
@: data-pager-@key="@Request.QueryString[key]"
    }    
}


@{
    int size = (int) Model.PageSize;
    int total = (int) Model.TotalCount;
    string url = (string) Model.Url;    
}

<div class="pager g-clear">
@for(int i = 1; i < Math.Ceiling((double)total/size)+1; i++)
{
    <a href="@url?page=@i&size=@size@GetParams()" class="pager__item js-cms-pager-link js-cms-pager-link-@i @GetCurrent(i)" @GetDataParams() data-url="@url" data-page="@i" data-size="@size" data-container=".js-pager-container">@i</a>
}    
</div>        